# -*- coding: utf-8 -*-
# @Time : 2019/2/24 18:43
# @Author : chen
# @Site : 
# @File : job.py
# @Software: PyCharm
from redis import Redis
from rq import Queue
import time

from test.works import count_words_at_url, tosleep


import os
import redis
from rq import Worker, Queue, Connection

listen = ['high', 'default', 'low']
redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')
conn = redis.from_url(redis_url)
if __name__ == '__main__':
    # with Connection(conn):
    #     worker = Worker(map(Queue, listen))
    #     worker.work()

    q = Queue(connection=Redis())
    print(time.ctime())
    for i in range(5, 1, -1):
        q.enqueue(tosleep, i)
    print(time.ctime())
    # result = q.enqueue(count_words_at_url, "http://www.baidu.com")
    # print(time.ctime())
    # print(result)